#include<cstdio>

int func(int a, int b) {
    int one, two, three;
    one = a > b ? a : b;
    two = a > b ? b : a;
    three = one % two;
    if (three == 0)
        return two;
    else
        return func(two, three);
}

int main() {
    int a, b, result;
    scanf("%d%d", &a, &b);
    printf("%d", func(a,b));
    return 0;
}